﻿using System;
using System.Data.SqlClient;
using System.Windows.Forms;
using Elkomp;

namespace MedicinskiUslugi {

	public partial class frmMedicinskiUslugi : FormaBrowse {
		SqlConnection con = new SqlConnection();
		SqlCommand com = new SqlCommand();

		public frmMedicinskiUslugi() {
			InitializeComponent();
			btnOk.Visible = false;
		}

		public frmMedicinskiUslugi( bool zoom ) {
			InitializeComponent();
			btnOk.Visible = true;
			zoom = true;
		}

		private void SelcectionCHanged( object sender, EventArgs e ) {
			if ( this.tblMedicinskiUslugiGrid.CurrentRow != null ) {
				dr = this.medicinskiUslugiDataSet.tblMedicinskiUslugi[this.tblMedicinskiUslugiGrid.CurrentRow.Index];
			}
		}

		public override void NovZapis( object sender, EventArgs e ) {
			this.tblMedicinskiUslugiGrid.Insert();
			base.NovZapis( sender, e );
		}

		public override void IzmeniZapis( object sender, EventArgs e ) {
			this.tblMedicinskiUslugiGrid.Edit();
			base.IzmeniZapis( sender, e );
		}

		private void frmMedicinskiUslugi_Load( object sender, EventArgs e ) {
			Navigator.BindingSource = tblMedicinskiUslugiBindingSource;
			this.tblMedicinskiUslugiTableAdapter.Fill( this.medicinskiUslugiDataSet.tblMedicinskiUslugi );
		}

		private void btnPrebaraj_Click( object sender, EventArgs e ) {
			this.tblMedicinskiUslugiTableAdapter.Fill( this.medicinskiUslugiDataSet.tblMedicinskiUslugi );
			this.tblMedicinskiUslugiBindingSource.Filter = " Sifra LIKE '%" + Sifra.Text + "%' ";
		}

		public override void IzbrisiZapis( object sender, EventArgs e ) {
			if ( this.tblMedicinskiUslugiGrid.CurrentRow != null ) {
				DialogResult opc;
				opc = MessageBox.Show( "Дали сте сигурни ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
				if ( opc == DialogResult.Yes ) {
					this.tblMedicinskiUslugiGrid.Rows.Remove( tblMedicinskiUslugiGrid.CurrentRow );
					this.tableAdapterManager.UpdateAll( this.medicinskiUslugiDataSet );
				}
			}

			base.IzbrisiZapis( sender, e );
		}

		private void tblMedicinskiUslugiGrid_DataInsert() {
			this.tblMedicinskiUslugiTableAdapter.Fill( this.medicinskiUslugiDataSet.tblMedicinskiUslugi );
		}

		private void SelcectionCHanged( object sender, DataGridViewCellEventArgs e ) {
		}
	}
}